import router from '../router/index.js'
import {getToken} from './token-util.js'


const authList = ['/company/second', '/auth-redirect', '/bind', '/register']


router.beforeEach((to, from, next) => {
    if (getToken()) {
        if (to.path === '/company/login') {
            next({path: '/company/home'});//跳转到
        } else {
            next();
        }
    } else {
        //判断当前页面是否需要权限验证
        if (authList.indexOf(to.path) !== -1) {
            //不需要验证
            next();
        } else {
            next('/'); // 否则全部重定向到登入页
        }
    }
});